class Solution:
    def checkPowersOfThree(self, n: int) -> bool:
      # 三进制不可能出现2
      while n:
        if n % 3 == 2:
          return False
        n //= 3
      return True